blob: 61a479abe9c0639c6eb2ea743d30ee340c2e91cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import Qr from 'qrcode-base64';
import { get } from '$lib/utils';
import { redirect } from '@sveltejs/kit';
export async function load({ depends, params, url }) {
depends('app:invoice');
let { hash } = params;
let invoice = await get(`/invoice?hash=${hash}`);
let { amount, received } = invoice;
amount = parseInt(amount);
let paid = (!amount && received) || (amount > 0 && received >= amount);
if (paid && !url.pathname.endsWith('paid')) throw redirect(307, `/invoice/${hash}/paid`);
let sm = Qr.drawImg(invoice.text, { size: 300 });
return { hash, invoice, sm, lg: sm };
}
|